<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>方形</title>
</head>
<body>
<canvas width="200" height="200" id="canvas"></canvas>
</body>
<script>
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');

  var p = new Path2D('M10 10 h 80 v 80 h -80 Z');
  ctx.fill(p);


</script>
</html>